import { BufferAttribute, BufferGeometry, Group, Line, LineBasicMaterial } from 'three';

function createLine(polygonArr){
    const group = new Group();
    polygonArr.forEach(polygon=>{
        const pointArr = [];
        polygon[0].forEach(elem=>{
            (<any>pointArr).push(elem[0], elem[1], 0);
        });
        group.add(line(pointArr));
    });
    return group;
}

function line(pointArr){
    const geometry = new BufferGeometry();
    geometry.attributes.position = new BufferAttribute(new Float32Array(pointArr), 3);
    const line = new LineBasicMaterial({
        color:0x00ffff
    });
    const lineMesh = new Line(geometry, line);
    return lineMesh;
}
export { createLine };